<?php
/**
 * Created by PhpStorm.
 * User: Chase
 * Date: 2017/7/18
 */

namespace app\mobile\controller;


use app\classes\model\ClassModel;
use think\Db;
use cmf\controller\AdminBaseController;


class HolidayController extends AdminBaseController
{

    public function mobileindex()
    {
        $admin_shop_id = $this->admin_shop_id;
        $param = $this->request->param();
        //店铺ID
        $param['admin_shop_id'] = $admin_shop_id;

        $teacher_homework = new TeacherHomeworkModel();
        $data = $teacher_homework->getList($param);

        //所有的班级
        $class = Db::name('class')->where(['delete_time' => 0])->select()->toArray();
        //处理内容输出
        foreach ($data as $k => $v) {
            $v['content'] = trim(htmlspecialchars_decode($v['content']), '');
            $data[$k] = $v;
        }
        $current_id = cmf_get_current_admin_id();

        //角色
        $role_id = Db::name('role_user')->alias('c')
            ->join('role r', 'r.id=c.role_id')
            ->where(['user_id' => $current_id])->value('r.id');
        //出去所有的老师
        $all_teacher = Db::name('user')->alias('u')->field('u.*')
            ->join('role_user r', 'r.user_id=u.id')
            ->where(['u.user_status' => 1, 'r.role_id' => 4])
            ->select()
            ->toArray();

        $class_all = $teacher_homework->class_all();

        $this->assign('role_id', $role_id);
        $this->assign('all_teacher', $all_teacher);
        $this->assign('class', $class);
        $this->assign('data', $data);
        $this->assign('class_all', $class_all);
        $this->assign('param', $param);
        $this->assign('page', $data->render());
        return $this->fetch();
    }


}